<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function findMostWord(article) {
            // 合法性判断
            if (!article) return;
            // 参数处理
            article = article.trim().toLowerCase();
            let wordList = article.match(/[a-z]+/g),
                visited = [],
                maxNum = 0,
                maxWord = "";
            article = " " + wordList.join("  ") + " ";
            // 遍历判断单词出现次数
            wordList.forEach(function (item) {
                if (visited.indexOf(item) < 0) {
                    // 加入 visited 
                    visited.push(item);
                    let word = new RegExp(" " + item + " ", "g"),
                        num = article.match(word).length;
                    if (num > maxNum) {
                        maxNum = num;
                        maxWord = item;
                    }
                }
            });
            return maxWord + "  " + maxNum;
        }
    </script>
</body>

</html>